import {getRoadSelectList, getRoadSectionSelectList,getRoadSectionInfo2,getSlopeNo} from '@/services/model/road-mgmt'
import constUrl from '@/services/env'
import Format from '@/utils/format';
export default {
  props: ['roadId'],
  data() {
    return {
      // 列表勾选的数据
      selectionList: [],
      roadList: [],
      fileList: [],
      bidSectionList: [],
      otherWater: false,
      otherGroundWater: false,
      otherEasy: false,
      otherSpecial: false,
      roadSectionInfo:{},
      slopeNo:''
    }
  },
  filters: {
    // 时间格式化
    formatTimer(timer) {
      if(timer){
        return Format(new Date(timer), 'yyyy年MM月dd日')
      }
      return ''
    },
    // 时间格式化
    formatTimer2(timer) {
      if(timer){
        return Format(new Date(timer), 'yyyy-MM-dd hh:mm:ss')
      }
      return ''
    }
  },
  methods: {
    //处理文件下载地址
    filePathHandle(val) {
      if(val){
        this.fileList = val.map(x => {
          return {
            url: constUrl + x.url,
            name: x.name
          }
        })
        return this.fileList
      }else{
        return []
      }
    },

    //获取路线列表
    async getRoadList() {
      const {data} = await getRoadSelectList()
      this.roadList = data
    },
    //获取组织下的路线列表
    async getRoadListByDept(deptId) {
      const {data} = await getRoadSelectList({deptId:deptId})
      return data
    },

    //根据路线id获取区间列表
    async getBidSectionList(roadId) {
      const {data} = await getRoadSectionSelectList({page: 1, pageSize: 999, roadId: roadId})
      this.bidSectionList = data
      this.sectionList = data
    },
    //根据路线id获取一个区间详情
    async getRoadSectionInfo(form) {
      const {data} = await getRoadSectionInfo2(form)
      this.roadSectionInfo = data
    },
    async getNo(type){
      let form = {
        roadId: this.currentRow.roadId,
        type: type,
        deptTreeId: this.currentRow.deptTreeId,
        position: this.currentRow.position,
        startPointBig: this.currentRow.startPointBig,
        endPointBig: this.currentRow.endPointBig,
        startPointSmall: this.currentRow.startPointSmall,
        endPointSmall: this.currentRow.endPointSmall,
      }
      const {data} = await getSlopeNo(form)
      return data
    },

    // 删除设计资料-防护信息
    handleDeleteProtectionDetail(index) {
      this.currentRow.protectionDetailList.splice(index, 1)
    },
    // 添加设计资料-防护信息
    addProtectionDetail() {
      let item = {
        level: '',           //级数
        gradient: "",       //坡率
        dept: "",           //支护措施
        size: "",         //规格尺寸
        count: '',           //数量
        remark: "",
      }
      this.currentRow.protectionDetailList.push(item)
    },

    //如果技术资料-地表排水措施选择其他
    ChangeOtherWater() {
      if (this.currentRow.waterDrainStepList.indexOf(5) > -1) {
        this.otherWater = true
      } else {
        this.otherWater = false
      }
    },
    //如果技术资料-地下排水措施选择其他
    ChangeOtherGroundWater() {
      if (this.currentRow.groundwaterDrainStepList.indexOf(5) > -1) {
        this.otherGroundWater = true
      } else {
        this.otherGroundWater = false
      }
    },
    //如果技术资料-地表排水措施选择其他
    ChangeOtherEasyMonitor() {
      if (this.currentRow.easyMonitorPlanList.indexOf(3) > -1) {
        this.otherEasy = true
      } else {
        this.otherEasy = false
      }
    },
    //如果技术资料-地下排水措施选择其他
    ChangeOtherSpecialMonitor() {
      if (this.currentRow.specialMonitorPlanList.indexOf(5) > -1) {
        this.otherSpecial = true
      } else {
        this.otherSpecial = false
      }
    },
  },
  created() {

  },

}
